package com.ihg.hiex.entity.session.after;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.user.Delegate;

/**
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "session_report")
public class SessionReport {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 所属Session */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Session session;
    
    /** 所属 Delegate */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Delegate delegate;
    
    /** 名称 */
    private String name;
    
    /** 描述 */
    private String description;
    
    /** report url*/
    private String reportUrl;
    
    /** ppt */
    private String ppt;
    
    /** wave complete report */
    private String waveReport;
    
    /** wave delegate report */
    private String waveDelegateReport;
    
    /** swift report */
    private String swiftReport;
    
    /** delegate final report */
    private String delegateFinalReport;
    
    /** delegate final report generate status*/
    @Enumerated(EnumType.STRING)
    private ReportGenerateStatus delegateFinalReportStatus;
    
    /** 学员报告发送状态 */
    @Enumerated(EnumType.STRING)
    private ReportSendStatus delegateSendStatus;
    
    /** coach final report */
    private String managerFinalReport;
    
    /** coach final report generate status*/
    @Enumerated(EnumType.STRING)
    private ReportGenerateStatus managerFinalReportStatus;
    
    /** 经理报告发送状态 */
    @Enumerated(EnumType.STRING)
    private ReportSendStatus managerSendStatus;
    
    /** assessor final report */
    private String peoplePlaningFinalReport;
    
    /** assessor final report generate status*/
    @Enumerated(EnumType.STRING)
    private ReportGenerateStatus peoplePlaningFinalReportStatus;
    
    /** HR report */
    private String hrReport;
    
    /** 上传时间 */
    private Date createTime;
    
    private Date lastUpdateTime;
    
    private Long lastOperator;
    
    /** session report类型 */
    @Enumerated(EnumType.STRING)
    private SessionReportType type;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor 
     */
    public SessionReport() {
    }
    
    /**
     * 
     * @param session
     * @param delegate
     * @param ppt
     * @param lastOperator
     */
    public SessionReport(Session session, Delegate delegate, String ppt, Long lastOperator) {
        this.session = session;
        this.delegate = delegate;
        this.ppt = ppt;
        this.delegateSendStatus = ReportSendStatus.UNSENT;
        this.managerSendStatus = ReportSendStatus.UNSENT;
        this.delegateFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.managerFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.peoplePlaningFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        this.disabled = false;
    }
    
    /**
     * 
     * @param session
     * @param delegate
     * @param waveReport
     * @param waveDelegateReport
     * @param swiftReport
     * @param lastOperator
     */
    public SessionReport(Session session, Delegate delegate, String waveReport, String waveDelegateReport, String swiftReport, Long lastOperator) {
        this.session = session;
        this.delegate = delegate;
        this.waveReport = waveReport;
        this.waveDelegateReport = waveDelegateReport;
        this.swiftReport = swiftReport;
        this.delegateSendStatus = ReportSendStatus.UNSENT;
        this.managerSendStatus = ReportSendStatus.UNSENT;
        this.delegateFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.managerFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.peoplePlaningFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        this.disabled = false;
    }
    
    /**
     * 
     * @param session
     * @param delegate
     * @param reportUrl
     * @param lastOperator
     * @param reportType
     */
    public SessionReport(Session session, Delegate delegate, String reportUrl, Long lastOperator, String reportType) {
        this.session = session;
        this.delegate = delegate;
        this.editReport(reportUrl, reportType);
        this.delegateSendStatus = ReportSendStatus.UNSENT;
        this.managerSendStatus = ReportSendStatus.UNSENT;
        this.delegateFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.managerFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.peoplePlaningFinalReportStatus = ReportGenerateStatus.UNGENERATED;
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        this.disabled = false;
    }
    
    /**
     * 
     * @param ppt
     * @param lastOperator
     * @return
     */
    public SessionReport editPpt(String ppt, Long lastOperator) {
        this.ppt = ppt;
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        return this;
    }
    
    /**
     * 
     * @param waveReport
     * @param swiftReport
     * @param lastOperator
     * @return
     */
    public SessionReport editReport(String waveReport, String swiftReport, Long lastOperator) {
        this.waveReport = waveReport;
        this.swiftReport = swiftReport;
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        return this;
    }
    
    /**
     * 
     * @param reportUrl
     * @param lastOperator
     * @param reportType
     * @return
     */
    public SessionReport editReport(String reportUrl, Long lastOperator, String reportType) {
        this.editReport(reportUrl, reportType);
        this.lastOperator = lastOperator;
        this.lastUpdateTime = new Date();
        return this;
    }
    
    /**
     * 
     * @param reportUrl
     * @param reportType
     * @return
     */
    public SessionReport editReport(String reportUrl, String reportType) {
        if(reportType.equalsIgnoreCase("waveReport")) {
            this.waveReport = reportUrl;
        } else if (reportType.equalsIgnoreCase("swiftReport")) {
            this.swiftReport = reportUrl;
        } else if (reportType.equalsIgnoreCase("delegateFinalReport")) {
            this.delegateFinalReport = reportUrl;
            this.delegateFinalReportStatus = ReportGenerateStatus.GENERATED;
        } else if (reportType.equalsIgnoreCase("coachFinalReport")) {
            this.managerFinalReport = reportUrl;
            this.managerFinalReportStatus = ReportGenerateStatus.GENERATED;
        } else if (reportType.equalsIgnoreCase("assessorFinalReport")) {
            this.peoplePlaningFinalReport = reportUrl;
            this.peoplePlaningFinalReportStatus = ReportGenerateStatus.GENERATED;
        } else if (reportType.equalsIgnoreCase("hrReport")) {
            this.hrReport = reportUrl;
        }
        return this;
    }
    
    /**
     * @param reportType
     * @return
     */
    public SessionReport sendReport(String reportType) {
        if (reportType.equalsIgnoreCase("delegateFinalReport")) {
            this.delegateSendStatus = ReportSendStatus.SENDING;
        } else if (reportType.equalsIgnoreCase("managerFinalReport")) {
            this.managerSendStatus = ReportSendStatus.SENDING;
        }
        return this;
    }
    
    /**
     * @param reportType
     * @return
     */
    public SessionReport sentReport(String reportType) {
        if (reportType.equalsIgnoreCase("delegateFinalReport")) {
            this.delegateSendStatus = ReportSendStatus.SENT;
        } else if (reportType.equalsIgnoreCase("managerFinalReport")) {
            this.managerSendStatus = ReportSendStatus.SENT;
        }
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the session
     */
    public Session getSession() {
        return session;
    }

    /**
     * @return the delegate
     */
    public Delegate getDelegate() {
        return delegate;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the reportUrl
     */
    public String getReportUrl() {
        return reportUrl;
    }

    /**
     * @return the ppt
     */
    public String getPpt() {
        return ppt;
    }

    /**
     * @return the waveReport
     */
    public String getWaveReport() {
        return waveReport;
    }

    /**
     * @return the waveDelegateReport
     */
    public String getWaveDelegateReport() {
        return waveDelegateReport;
    }

    /**
     * @return the swiftReport
     */
    public String getSwiftReport() {
        return swiftReport;
    }

    /**
     * @return the delegateFinalReport
     */
    public String getDelegateFinalReport() {
        return delegateFinalReport;
    }

    /**
     * @return the delegateFinalReportStatus
     */
    public ReportGenerateStatus getDelegateFinalReportStatus() {
        return delegateFinalReportStatus;
    }

    /**
     * @return the delegateSendStatus
     */
    public ReportSendStatus getDelegateSendStatus() {
        return delegateSendStatus;
    }

    /**
     * @return the managerFinalReport
     */
    public String getManagerFinalReport() {
        return managerFinalReport;
    }

    /**
     * @return the managerFinalReportStatus
     */
    public ReportGenerateStatus getManagerFinalReportStatus() {
        return managerFinalReportStatus;
    }

    /**
     * @return the managerSendStatus
     */
    public ReportSendStatus getManagerSendStatus() {
        return managerSendStatus;
    }

    /**
     * @return the peoplePlaningFinalReport
     */
    public String getPeoplePlaningFinalReport() {
        return peoplePlaningFinalReport;
    }

    /**
     * @return the peoplePlaningFinalReportStatus
     */
    public ReportGenerateStatus getPeoplePlaningFinalReportStatus() {
        return peoplePlaningFinalReportStatus;
    }

    /**
     * @return the hrReport
     */
    public String getHrReport() {
        return hrReport;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastUpdateTime
     */
    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the type
     */
    public SessionReportType getType() {
        return type;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param session the session to set
     */
    public void setSession(Session session) {
        this.session = session;
    }

    /**
     * @param delegate the delegate to set
     */
    public void setDelegate(Delegate delegate) {
        this.delegate = delegate;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @param reportUrl the reportUrl to set
     */
    public void setReportUrl(String reportUrl) {
        this.reportUrl = reportUrl;
    }

    /**
     * @param ppt the ppt to set
     */
    public void setPpt(String ppt) {
        this.ppt = ppt;
    }

    /**
     * @param waveReport the waveReport to set
     */
    public void setWaveReport(String waveReport) {
        this.waveReport = waveReport;
    }

    /**
     * @param waveDelegateReport the waveDelegateReport to set
     */
    public void setWaveDelegateReport(String waveDelegateReport) {
        this.waveDelegateReport = waveDelegateReport;
    }

    /**
     * @param swiftReport the swiftReport to set
     */
    public void setSwiftReport(String swiftReport) {
        this.swiftReport = swiftReport;
    }

    /**
     * @param delegateFinalReport the delegateFinalReport to set
     */
    public void setDelegateFinalReport(String delegateFinalReport) {
        this.delegateFinalReport = delegateFinalReport;
    }

    /**
     * @param delegateFinalReportStatus the delegateFinalReportStatus to set
     */
    public void setDelegateFinalReportStatus(ReportGenerateStatus delegateFinalReportStatus) {
        this.delegateFinalReportStatus = delegateFinalReportStatus;
    }

    /**
     * @param delegateSendStatus the delegateSendStatus to set
     */
    public void setDelegateSendStatus(ReportSendStatus delegateSendStatus) {
        this.delegateSendStatus = delegateSendStatus;
    }

    /**
     * @param managerFinalReport the managerFinalReport to set
     */
    public void setManagerFinalReport(String managerFinalReport) {
        this.managerFinalReport = managerFinalReport;
    }

    /**
     * @param managerFinalReportStatus the managerFinalReportStatus to set
     */
    public void setManagerFinalReportStatus(ReportGenerateStatus managerFinalReportStatus) {
        this.managerFinalReportStatus = managerFinalReportStatus;
    }

    /**
     * @param managerSendStatus the managerSendStatus to set
     */
    public void setManagerSendStatus(ReportSendStatus managerSendStatus) {
        this.managerSendStatus = managerSendStatus;
    }

    /**
     * @param peoplePlaningFinalReport the peoplePlaningFinalReport to set
     */
    public void setPeoplePlaningFinalReport(String peoplePlaningFinalReport) {
        this.peoplePlaningFinalReport = peoplePlaningFinalReport;
    }

    /**
     * @param peoplePlaningFinalReportStatus the peoplePlaningFinalReportStatus to set
     */
    public void setPeoplePlaningFinalReportStatus(ReportGenerateStatus peoplePlaningFinalReportStatus) {
        this.peoplePlaningFinalReportStatus = peoplePlaningFinalReportStatus;
    }

    /**
     * @param hrReport the hrReport to set
     */
    public void setHrReport(String hrReport) {
        this.hrReport = hrReport;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastUpdateTime the lastUpdateTime to set
     */
    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param type the type to set
     */
    public void setType(SessionReportType type) {
        this.type = type;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
